package com.shujia.mr.tuijian;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RecommendReduce extends Reducer<Text, LongWritable, Text, Text> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, Text>.Context context) throws IOException, InterruptedException {
        //<"hadoop-hello",[-1,1,1,-1]>

        boolean flag = true;
        for (LongWritable value : values) {
            if(value.get()==1){
                context.write(key,new Text("直接好友"));
                flag = false;
                break;
            }
        }

        if(flag){
            context.write(key,new Text("间接好友"));
        }

    }
}
